package ca.camosun.bouncer.game;

public class Paddle {
	private int xWidth;
	private int yWidth;
	private int totalAccumulatedHeight;
	private Ball ball;

	public Paddle(int xWidthIn, int yWidthIn) {
		xWidth = xWidthIn;
		yWidth = yWidthIn;

		ball = new Ball(xWidth / 2, yWidth / 2);
	}

	public int getBallX() {
		return ball.getX();
	}

	public int getBallY() {
		return ball.getY();
	}

	public int getTotalAccumulatedHeight() {
		return totalAccumulatedHeight;
	}

	public boolean isBallInPlay() {
		return ball.isInBounds(0, xWidth, 0, yWidth);
	}

	public void attemptBounce(int inX, int inY, int inHeight) {
		ball.bounce(inX, inY);

		if (!isBallInPlay()) {
			return;
		}

		if (inHeight > 0) {
			totalAccumulatedHeight += inHeight;
		}
	}

}
